<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Contents extends Front_Controller{

	function Contents(){
        parent::Front_Controller();
	}
	
	function index(){
        $this->add('name', get_class($this));
	}
	
	function product_price(){
		/*$CI = &get_instance();
		$productId = $_GET['pid'];
		$franchiseId = $_GET['fid'];
		$qry = "SELECT 
		  product.price
		FROM
		  product
		WHERE
		  product.product_id = $productId AND 
		  product.admin_id = $franchiseId
		LIMIT 1";
		$results = $CI->db->query($qry);
        if ($results->num_rows() > 0)
        {
           $row = $results->row_array();
        }
        $tid = ($row['price'])?$row['price']:'';*/
        $CI = & get_instance();
        $CI->load->module_model('blocks.utils_model');
        $price = $CI->utils_model->get_term_price($_GET['term_id'], $_GET['pid']);
        
        $CI->load->module_model('front.configurations.config_model');
        $client_fee = $CI->config_model->get_config(NEW_CLIENT_FEE);
        $total_price = $price + $client_fee->value;
        
        $this->add('price', n($price));
        $this->add('new_fee', n($client_fee->value));
        $this->add('total_price', n($total_price));
	}
    
    function check_enrol_date(){
        $CI = & get_instance();
        $CI->load->module_model('blocks.term');
        $CI->term->set_id($_GET['term_id']);
        $CI->term->get_by_fid();
        if(date('Ymd', strtotime($CI->term->enrol_date)) > date('Ymd'))
            echo '<cannot_enrol>1</cannot_enrol>';
        $this->view('product_price');
    }

}